/**
 * Copyright (c) Software Institude of PKU
 * All rights reserved. 
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */
package edu.pku.sei.modeler.model.uml.UseCases;
// imports:
import org.w3c.dom.Element;

import edu.pku.sei.gefcommon.descriptor.annotation.MethodProperty;
import edu.pku.sei.modeler.model.common.*;
import edu.pku.sei.modeler.model.core.*;
import edu.pku.sei.modeler.model.xml.XMLUtility;

import edu.pku.sei.modeler.model.uml.Kernel.VisibilityKind;
import edu.pku.sei.modeler.model.uml.Kernel.Constraint;
import edu.pku.sei.modeler.model.uml.Dependencies.Dependency;
import edu.pku.sei.modeler.model.uml.Kernel.Comment;
import edu.pku.sei.modeler.model.uml.Kernel.UMLElement;

import edu.pku.sei.modeler.model.uml.Kernel.DirectedRelationship;
import edu.pku.sei.modeler.uml.modelHelper.ModelPackage;

/**
 * @generated
 *
 */
public class Extend extends DirectedRelationship implements IExtend {
	// attributes
	
	protected UseCase extendedCase;
	
	
	
	protected String name;
	
	protected VisibilityKind visibility;
	
	protected String qualifiedName;
	
	
	// references
	
	protected MetaTypedList condition;
	
	
	
	protected MetaTypedList supplierDependency;
	
	protected MetaTypedList ownedComment;
	
	protected MetaTypedList ownedElement;
	
	// getters & setters for attributes
	
	public UseCase getExtendedCase() {
		return extendedCase;
	}
	public void setExtendedCase(UseCase newExtendedCase) {
		UseCase oldextendedCase = extendedCase;
		extendedCase = newExtendedCase;
		firePropertyChange(ModelPackage.EXTEND_EXTENDEDCASE, oldextendedCase, newExtendedCase);
	}
	
	@MethodProperty(
			id = "EXTEND_NAME",
			catalog = "Model",
			name = ModelPackage.NAMEDELEMENT_NAME,
			setter = "setName"
			)
	
	public String getName() {
		return name;
	}
	public void setName(String newName) {
		String oldname = name;
		name = newName;
		firePropertyChange(ModelPackage.NAMEDELEMENT_NAME, oldname, newName);
	}
	
	public VisibilityKind getVisibility() {
		return visibility;
	}
	public void setVisibility(VisibilityKind newVisibility) {
		VisibilityKind oldvisibility = visibility;
		visibility = newVisibility;
		firePropertyChange(ModelPackage.NAMEDELEMENT_VISIBILITY, oldvisibility, newVisibility);
	}
	
	@MethodProperty(
			id = "EXTEND_QUALIFIEDNAME",
			catalog = "Model",
			name = ModelPackage.NAMEDELEMENT_QUALIFIEDNAME,
			setter = "setQualifiedName"
			)
	
	public String getQualifiedName() {
		return qualifiedName;
	}
	public void setQualifiedName(String newQualifiedName) {
		String oldqualifiedName = qualifiedName;
		qualifiedName = newQualifiedName;
		firePropertyChange(ModelPackage.NAMEDELEMENT_QUALIFIEDNAME, oldqualifiedName, newQualifiedName);
	}
	
	// getters for references
	
	public MetaTypedList getCondition() {
		if(condition == null) {
			condition = new MetaTypedList(Constraint.class, this, ModelPackage.EXTEND_CONDITION);
		}
		return condition;
	}
	
	public MetaTypedList getSupplierDependency() {
		if(supplierDependency == null) {
			supplierDependency = new MetaTypedList(Dependency.class, this, ModelPackage.NAMEDELEMENT_SUPPLIERDEPENDENCY);
		}
		return supplierDependency;
	}
	
	public MetaTypedList getOwnedComment() {
		if(ownedComment == null) {
			ownedComment = new MetaTypedList(Comment.class, this, ModelPackage.UMLELEMENT_OWNEDCOMMENT);
		}
		return ownedComment;
	}
	
	public MetaTypedList getOwnedElement() {
		if(ownedElement == null) {
			ownedElement = new MetaTypedList(UMLElement.class, this, ModelPackage.UMLELEMENT_OWNEDELEMENT);
		}
		return ownedElement;
	}
	
	// save & load
	public void serialize(Element root) {
		super.serialize(root);
		// attributes
		
		XMLUtility.xmlInstance.serializeNode(root, ModelPackage.EXTEND_EXTENDEDCASE, extendedCase);
		
		XMLUtility.xmlInstance.serializeAttribute(root, ModelPackage.NAMEDELEMENT_NAME, name);
		
		XMLUtility.xmlInstance.serializeNode(root, ModelPackage.NAMEDELEMENT_VISIBILITY, visibility);
		
		XMLUtility.xmlInstance.serializeAttribute(root, ModelPackage.NAMEDELEMENT_QUALIFIEDNAME, qualifiedName);
		
		// references
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.EXTEND_CONDITION, condition);
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.NAMEDELEMENT_SUPPLIERDEPENDENCY, supplierDependency);		
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.UMLELEMENT_OWNEDCOMMENT, ownedComment);
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.UMLELEMENT_OWNEDELEMENT, ownedElement);
		
	}
	
	public void deSerialize(Element root) {
		super.deSerialize(root);
		// attributes
		
		extendedCase = (UseCase)XMLUtility.xmlInstance.deSerializeNode(root, ModelPackage.EXTEND_EXTENDEDCASE, this);
		
		name = XMLUtility.xmlInstance.deSerializeString(root, ModelPackage.NAMEDELEMENT_NAME);
		
		visibility = (VisibilityKind)XMLUtility.xmlInstance.deSerializeNode(root, ModelPackage.NAMEDELEMENT_VISIBILITY, this);
		
		qualifiedName = XMLUtility.xmlInstance.deSerializeString(root, ModelPackage.NAMEDELEMENT_QUALIFIEDNAME);
		
		// references
		
		this.getCondition().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.EXTEND_CONDITION));
		
		this.getSupplierDependency().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.NAMEDELEMENT_SUPPLIERDEPENDENCY, this));
		
		this.getOwnedComment().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.UMLELEMENT_OWNEDCOMMENT));
		
		this.getOwnedElement().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.UMLELEMENT_OWNEDELEMENT));
		
	}
	
	public void dynamicSet(String featureID, Object value) {
		if(featureID == null || "".equals(featureID)) {
			return;
		}
		// attributes
		
		else if(ModelPackage.EXTEND_EXTENDEDCASE.equals(featureID)) {
			extendedCase = (UseCase)value;
		}
		
		else if(ModelPackage.NAMEDELEMENT_VISIBILITY.equals(featureID)) {
			visibility = (VisibilityKind)value;
		}
		
		// references
		
		else if(ModelPackage.NAMEDELEMENT_SUPPLIERDEPENDENCY.equals(featureID)) {
			getSupplierDependency().add(value);
		}
		
		else
			super.dynamicSet(featureID, value);
	}
}
 
 
 
 
 